package org.lyy.controller;

import org.lyy.entity.OrderDetail;
import org.lyy.entity.ProductInfo;
import org.lyy.service.OrderDetailService;
import org.lyy.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin//跨域
@RestController//@Controller+@ResponseBody
@RequestMapping("/orderDetail/")
public class OrderDetailController {

    @Autowired
    private OrderDetailService orderDetailService;
    @Autowired
    private ProductService productService;
    @RequestMapping("upload")
    public OrderDetail orderUpload(HttpServletRequest request){
        OrderDetail OD = new OrderDetail();
        String name = request.getParameter("name");
        String num = request.getParameter("num");
        String price = request.getParameter("price");
        String kind = request.getParameter("kind");
        String paid = request.getParameter("paid");
        String orderId = request.getParameter("orderId");
        String productId = request.getParameter("productId");
        System.out.println(name);
        OD.setProductName(name);
        OD.setNum(num);
        OD.setProductPrice(price);
        OD.setProductKind(kind);
        OD.setProductPaid(paid);
        OD.setOrderId(orderId);
        OD.setProductId(productId);
        orderDetailService.save(OD);
        return OD;
    }
}
